home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows News 2010 Summer - Disc 1
/
WN_Ete2010_CD1.iso
/
Onglet5
/
Weezo
/
Weezo setup.exe
/
{code_appDir}
/
www
/
includes
/
mobileExplorerFunctions.php
< prev
next >
Wrap
PHP Script
|
2010-05-19
|
24KB
|
600 lines
<?php
/**
* Common explorer functions used by scripts displaying mobile devices pages
*
*
* PHP version 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
* @category NA
* @package NA
* @author Nicolas Bruley / Peer 2 World <contact@weezo.net>
* @copyright 2005-2008 Nicolas Bruley / Peer 2 World
* @license http://www.php.net/license/3_0.txt PHP License 3.0
* @version CVS: $Id:$
* @link http://www.weezo.net
* @since File available since Release 1.3.0
*/
require_once(INCLUDE_DIR.'mobileFunctions.php');
require_once(INCLUDE_DIR.'outputFunctions.php');
/**
* @desc Initialize mobile explorer specific settings
*
*/
function mefExplorerInit(){
if(cfRGetVar('resourceMobileConfigured')) return ;
cfRInitVar('itemsPerPageMobile',30); // Items per page - 0: unlimited, 10, 20, 50
cfRSetVar('itemsPerPage',cfRGetVar('itemsPerPageMobile')); // Items per page. Use itemsPerPageMobile for initiatlisation
cfRSetVar('itemsPerPagePos',0); // Current position (offset) in files
// Default shrinked / expanded image view (0: shrinked, 1: expanded, 2:fullsize)
cfRInitVar('viewImageZoom',0);
// Update directory content to see if some files are in it, in order to automatically select file/folder view
efDirUpdate(array('noThumbnails'=>1));
// If no files in, display folder view, else display files view
if($_ENV['weezoResEfFiles']['nbFiles']==0) cfRSetVar('view','folders'); else cfRSetVar('view','files');
// Adjust audio player to browser capabilities
if(!cfBGetVar(cfRGetVar('audioPlayer'))) cfRSetVar('audioPlayer',((cfBGetVar('flash'))?'flash':((cfBGetVar('wmp'))?'wmp':((cfBGetVar('qt'))?'qt':'qtReenc'))));
cfRSetVar('resourceMobileConfigured',1);
}
/**
* Entry point for mobile explorer scripts
*
*/
function mefExplorer(){
// Init explorer mobile-specific data
mefExplorerInit();
/*
***************************************************************************************************************************
* Process POST commands
***************************************************************************************************************************
*/
efProcessPOST();
if(isset($_POST['uploadGetId'])) require(INCLUDE_DIR.'uploadWindow.php');
/*
***************************************************************************************************************************
* Get files and subfolders list, generate thumbnails if needed
***************************************************************************************************************************
*/
efDirUpdate(array('includeRights'=>1,'noExtra'=>1)+((cfRGetVar('fileTypeFilter')!=array('image'))?array('noThumbnails'=>1):array()));
/*
***************************************************************************************************************************
* Insert HEAD, JS functions and form
***************************************************************************************************************************
*/
mfInsertHead(array('topControlsExtra'=>mefTopControls()));
mefInsertScripts();
// Images thumbnails generation & monitoring
if(isset($_ENV['thumbnailPhotoNeeded']) && is_array($_ENV['thumbnailPhotoNeeded'])) efMakePhotoThumbnails($_ENV['thumbnailPhotoNeeded']); unset($_ENV['thumbnailPhotoNeeded']);
if(!cfIsAsync() && cfRGetVar('view')!='tools') echo '<div id="mainDiv"></div>';
// If user is browsing folders
if(cfRGetVar('view')=='folders')
mefDisplayFolders();
// If user is browsing files
if(cfRGetVar('view')=='files')
mefDisplayFiles();
// If user is viewing tools (mdl, upload, remote dl...)
if(cfRGetVar('view')=='tools')
mefDisplayTools();
}
/**
* @desc Insert scripts needed by explorers
*
*/
function mefInsertScripts(){
if(cfIsAsync()) return ;
//outInsertStandardComForm($_SERVER['PHP_SELF'],cfUTF8Encode(cfResourceRelativePath(cfRGetVar('efCurrentDirectory'))));
outInsertStandardComForm($_SERVER['PHP_SELF'],cfUTF8Encode(cfResourceRelativePath(cfRGetVar('efCurrentDirectory'))));
// Common explorer js functions
if(!cfBGetVar('inlineJS')) echo cfScriptLink('mExplorer.js');
// Javascript
?>
<script type="text/javascript">
var eV="<?php echo cfRGetVar('view');?>";
var icoSdown='<?php echo outIcon('sdown');?>';
var icoSup='<?php echo outIcon('sup');?>';
var icoFold='<?php echo outIcon('fi/med/folder'); ?>';
var icoGo='/themes/mobile/go.gif';
var capRen="<?php echo cfCaptionJS('explorerEnterNewName');?>";
var capSup="<?php echo cfCaptionJS('genConfirmSuppress');?>";
var capExe="<?php echo cfCaptionJS('explorerEnterParameters');?>";
<?php
// iPhone orientation management
if(cfBGetVar('name')=='iPhone'){?>
function updateOrientation(){
if(window.orientation==undefined) return;
if(Math.abs(orientation)==90) {
dgn('viewport').setAttribute("content", "width=480, height=268, user-scalable=yes,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0");
D.body.style.height='268px';
}
else {
dgn('viewport').setAttribute("content", "width=320, height=416, user-scalable=yes,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0");
D.body.style.height='416px';
}
}
<?php
}
// Inline explorer scripts
if(cfBGetVar('inlineJS')) echo file_get_contents(cfAppDocRoot().'/js/mExplorer.js');
/***************************************************************************************************************
* All files (explorer)
**************************************************************************************************************/
if(cfRGetVar('fileTypeFilter')==false){
?>
function updtFiles(fl,prev,next){
files=fl;
fS=-1;
eV='files';setViewIco();
var out='<table class="liTable" cellspacing=0 cellpadding=0><colgroup><col width="1%"><col width="98%"><col width="1%"></colgroup>';
if(prev) out+='<tr class="li" onclick="setPos(this,\'prev\')"><td class="lil"> </td><td class="lic" style="text-align:center"><img src="<?php echo outIcon('sup');?>"></td><td class="lir"> </td></tr>';
for(i=0;i<fl.length;i++) {
out+='<tr id="tr'+i+'" class="li" onclick="sel(this,0)"><td class="lil"><p class="frLi16"><img src="'+fl[i][2]+'"></p></td><td class="lic"><div class="lits">'+fl[i][1]+'</div>'+fl[i][5]+'</td><td class="lir"><img src="'+icoGo+'"></td></tr>';
}
if(next) out+='<tr class="li" onclick="setPos(this,\'next\')"><td class="lil"> </td><td class="lic" style="text-align:center"><img src="<?php echo outIcon('sdown');?>"></td><td class="lir"> </td></tr>';
updtView(out+'</table>');
}
<?php
}
/***************************************************************************************************************
* Audio files
**************************************************************************************************************/
if(cfRGetVar('fileTypeFilter')==array('audio')){
?>
function updtFiles(fl,prev,next){
files=fl;
fS=-1;
eV='files';setViewIco();
var out='<table class="liTable" cellspacing=0 cellpadding=0><colgroup><col width="1%"><col width="98%"><col width="1%"></colgroup>';
<?php
// If browser / OS supports playlists, add playlist-related control
if(cfBGetVar('playlistFormat')) {?>
if(fl.length) out+='<tr class="li" onclick="mAddAll(this)" id="mAddTr"><td style="width:70px" class="lil"><img src="<?php echo outIcon('addMult')?>" class="ico"></td><td class="lic lit"><?php echo addslashes(cfCaption('explorerAudioPlaylistAdd'));?></td><td class="lir"> </td></tr><?php echo mfListSpacer();?>';
<?php
} // eo playlist
// Previous files control
?>
if(prev) out+='<tr class="li" onclick="setPos(this,\'prev\')"><td class="lil"> </td><td class="lic" style="text-align:center"><img src="<?php echo outIcon('sup');?>"></td><td class="lir"> </td></tr>';
<?php // Files ?>
for(i=0;i<fl.length;i++) {
out+='<tr id="tr'+i+'" class="li"><?php
if(cfBGetVar('name')=='IEMobile'){
?>
<td class="lil"><a href="javascript:view(dgi(\'tr'+i+'\'))"><img src="<?php echo outIcon('play')?>" class="nfrLi32"></a><?php } else { ?>
<td class="lil"><img src="<?php echo outIcon('play')?>" class="nfrLi32" onclick="view(dgi(\'tr'+i+'\'))"><?php }
if(cfBGetVar('playlistFormat')) {
if(cfBGetVar('name')=='IEMobile')
echo '<a href="javascript:mAdd(dgi(\\\'tr\'+i+\'\\\'),\\\'pl\\\')"><img src="'.outIcon('add').'" class="nfrLi32"></a>';
else
echo '<img src="'.outIcon('add').'" class="nfrLi32" onclick="mAdd(dgi(\\\'tr\'+i+\'\\\'),\\\'pl\\\')">';
}
?></td><td class="lic" onclick="sel(this.parentNode,0)"><div class="lits">'+fl[i][1]+'</div>'+fl[i][6]+'</td><td class="lir" onclick="sel(this.parentNode,0)"><img src="'+icoGo+'"></td></tr>';
}
if(next) out+='<tr class="li" onclick="setPos(this,\'next\')"><td class="lil"> </td><td class="lic" style="text-align:center"><img src="<?php echo outIcon('sdown');?>"></td><td class="lir"> </td></tr>';
updtView(out+'</table>');
}
<?php
}
/***************************************************************************************************************
* Video or multimedia files
**************************************************************************************************************/
if(is_array(cfRGetVar('fileTypeFilter')) && in_array('video',cfRGetVar('fileTypeFilter'))){
?>
function updtFiles(fl,prev,next){
files=fl;
fS=-1;
eV='files';setViewIco();
var out='<table class="liTable" cellspacing=0 cellpadding=0><colgroup><col width="1%"><col width="98%"><col width="1%"></colgroup>';
if(prev) out+='<tr class="li" onclick="setPos(this,\'prev\')"><td class="lil"> </td><td class="lic" style="text-align:center"><img src="<?php echo outIcon('sup');?>"></td><td class="lir"> </td></tr>';
for(i=0;i<fl.length;i++) {
out+='<tr id="tr'+i+'" class="li"><td class="lil" onclick="view(this.parentNode)"><img src="<?php echo outIcon('play')?>" class="frLi2"></td><td class="lic" onclick="sel(this.parentNode,0)"><div class="lits">'+fl[i][1]+'</div></td><td class="lir" onclick="sel(this.parentNode,0)"><img src="'+icoGo+'"></td></tr>';
}
if(next) out+='<tr class="li" onclick="setPos(this,\'next\')"><td class="lil"> </td><td class="lic" style="text-align:center"><img src="<?php echo outIcon('sdown');?>"></td><td class="lir"> </td></tr>';
updtView(out+'</table>');
}
<?php
}
/***************************************************************************************************************
* Images files
**************************************************************************************************************/
if(cfRGetVar('fileTypeFilter')==array('image')){
?>
var cT,margin=0;
function sT(){cT=new Date().getTime()}
function iS(i){
if(fS==i) return;
if(fS!=-1){
cn=dgi('td'+fS).childNodes;
cn[0].style.display='';
while(cn.length>1) dgi('td'+fS).removeChild(cn[1]);
}
fS=i;
return view();
}
function updtFiles(fl,prev,next){
files=fl;
fS=-1;
eV='files';setViewIco();
out='';
if(prev) out+='<table class="liTable" cellspacing=0 cellpadding=0><colgroup><col width="1%"><col width="89%"><col width="10%"></colgroup><tr class="li" onclick="setPos(this,\'prev\')"><td class="lil"> </td><td class="lic" style="text-align:center"><img src="'+icoSup+'"></td><td class="lir"> </td></tr></table><br/>';
for(i=0;i<fl.length;i++) {
out+='<img <?php if(cfRGetVar('fileViewAllowed')) {?>onclick="iS('+i+')"<?php } ?> src="'+fl[i][2]+'" style="width:'+imgw+'px;height:'+imgh+'px;margin:'+margin+'px">';
}
if(next) out+='<br/><table class="liTable" cellspacing=0 cellpadding=0><colgroup><col width="1%"><col width="89%"><col width="10%"></colgroup><tr class="li" onclick="setPos(this,\'next\')"><td class="lil"> </td><td class="lic" style="text-align:center"><img src="'+icoSdown+'"></td><td class="lir"> </td></tr></table>';
updtView('<div class="frame1">'+out+'</div>');
}
<?php
}
?>
var vA=new Array();
vA['dlBt']=new Array("dl(this)","<?php echo outIcon('dl');?>","<?php echo cfCaption('genDownload');?>");
<?php
// Multiple download / playlist add
if(is_array(cfRGetVar('fileTypeFilter')) && (in_array('audio',cfRGetVar('fileTypeFilter'))||in_array('video',cfRGetVar('fileTypeFilter')))){
?>
vA['mdlBt']=new Array("mAdd(this,'pl')","<?php echo outIcon('mdl');?>","<?php echo cfCaption('explorerAudioPlaylistAdd');?>");
<?php
}
else{
?>
vA['mdlBt']=new Array("mAdd(this)","<?php echo outIcon('mdl');?>","<?php echo cfCaption('explorerMultipleDownloadAdd');?>");
<?php
}
// View
if(is_array(cfRGetVar('fileTypeFilter')) && (in_array('audio',cfRGetVar('fileTypeFilter'))||in_array('video',cfRGetVar('fileTypeFilter')))){?>
vA['plBt']=new Array("view(this)","<?php echo outIcon('play');?>","<?php echo cfCaption('explorerAudioPlay');?>");
<?php } else{ ?>
vA['plBt']=new Array("view(this)","<?php echo outIcon('view');?>","<?php echo cfCaption('genView');?>");
<?php }?>
vA['renBt']=new Array("ren(this)","<?php echo outIcon('edit');?>","<?php echo cfCaption('explorerRename');?>");
vA['exeBt']=new Array("exe(this)","<?php echo outIcon('exec');?>","<?php echo cfCaption('explorerExecute');?>");
vA['supBt']=new Array("sup(this)","<?php echo outIcon('cancel');?>","<?php echo cfCaption('genDelete');?>");
</script>
<?php
}
/**
* @desc Top right explorer-specific controls
*
* @return string: HTML code
*/
function mefTopControls(){
$output='';
// Browse folders button
if(cfRGetVar('subFoldersIncluded')) $output.=mfButton(false,'javascript:setView(\'folders\')',outIcon('fi/med/folder'),'id="setViewFolders"',(cfRGetVar('view')=='folders')?'on':'');
// Browse files button
$output.=mfButton(false,'javascript:setView(\'files\')',outIcon('fi/med/icoBlank'),'id="setViewFiles"',(cfRGetVar('view')=='files')?'on':'');
// Tools button
if(mefHasTools()) {
if(is_array(cfRGetVar('fileTypeFilter')) && (in_array('audio',cfRGetVar('fileTypeFilter'))||in_array('video',cfRGetVar('fileTypeFilter'))))
$output.=mfButton(false,'javascript:setView(\'tools\')',outIcon('fi/med/icoM3U'),'id="setViewTools"',(cfRGetVar('view')=='tools')?'on':'');
else
$output.=mfButton(false,'javascript:setView(\'tools\')',outIcon('gearsM'),'id="setViewTools"',(cfRGetVar('view')=='tools')?'on':'');
}
return $output;
}
/**
* @desc Return true if resource has multiple downloads and/or upload
*
* @return boolean
*/
function mefHasTools(){
$filter=cfRGetVar('fileTypeFilter');
if(cfRGetVar('multipleDownloadAllowed') || (cfBGetVar('playlistFormat') && is_array($filter) && in_array('audio',$filter))) return true;
if(cfRGetVar('uploadAllowed')) return true;
return false;
}
/**
* @desc Return HTML code for multiple downloads list
*
* @return string
*/
function mefMultipleDownloadsInnerHTML(){
$output='';
if(cfRGetVar('playlist')) foreach (cfRGetVar('playlist') as $k=>$v) $output.='<div class="sli">'.cfUTF8Encode($v['label']).'</div>';
elseif(cfRGetVar('mDownloadList')) foreach (cfRGetVar('mDownloadList') as $k=>$v) $output.='<div class="sli"><img src="'.efIcon($k).'" class="frW ico16">'.cfUTF8Encode($k).'</div>';
return $output;
}
/**
* @desc output script needed for sync/async update of tools view
* @param array $options: options:
* 'noMAddAll': no mAddAll button (used by mobile music DB scripts)
*/
function mefDisplayTools($options=false){
$output='';
$filter=cfRGetVar('fileTypeFilter');
// Uploads
if(cfRGetVar('uploadAllowed')){
$output.='<div class="frame2">'.cfCaption('genFileUpload');
$output.='
<form name="uploadForm" method="post" enctype="multipart/form-data" action="upload.php">
<input type="hidden" name="UPLOAD_IDENTIFIER">
<input type="hidden" name="ulDir" id="ulDir">
<input type="hidden" name="postUlFile" id="postUlFile" value="">
<input type="hidden" name="resId" value="'.$_SESSION['activeResourceId'].'">
<input type="hidden" name="ulTransferId" id="ulTransferId" value="">
<input type="file" id="ubId" name="ulInput" size="7">';
$output.=mfButton(false,'javascript:ul()',outIcon('ok'));
$output.='</div>';
}
// Remote downloads
if(cfRGetVar('remoteDownloadAllowed')){
$output.='<div class="frame2">'.cfCaption('genDirectDownload');
$output.='<form name="ddBox" method="POST" onsubmit="return false">';
$output.='<input class="textInput" type="text" id="rdlInput" name="rdName" size="15" value="http://"> ';
$output.='<input type="hidden" name="resId" value="'.$_SESSION['activeResourceId'].'">';
$output.=mfButton(false,'javascript:rdl();',outIcon('ok'),'id=rdlBt');
$output.='</form></div>';
}
// Multiple downloads
if(cfRGetVar('multipleDownloadAllowed') || (cfBGetVar('playlistFormat') && is_array($filter) && in_array('audio',$filter))){
$output.='<div class="frame2"><div class="frame2Header">'.cfCaption('explorerMultipleDownload').'</div>';
// Multiple download & download buttons
$output.=mfButton(false,'javascript:mDownload()',outIcon('dl'))
.((isset($options['noMAddAll']))?'':mfButton(false,'javascript:mAddAll()',outIcon('addMult')))
.mfButton(false,'javascript:mSuppAll()',outIcon('eraser'));
// Playlist play all button
if(cfBGetVar('playlistFormat') && is_array($filter) && in_array('audio',$filter))
$output.=mfButton(false,'javascript:plPlayAll()',outIcon('play'));
// File's div
$output.='<div class="frame3" id="mdlF" style="height:80%;overflow:auto">';
$output.=mefMultipleDownloadsInnerHTML();
$output.='</div></div>';
}
if(cfIsAsync()) {
echo cfAsyncXMLInnerHTMLbyId($output,'mainDiv');
die(cfAsyncFooter());
}
echo '<div id="mainDiv">'.$output.'</div></body></html>';
}
/**
* @desc return JS array item corresponding to a file description
*
* @param array $value: properties of file
* @return string
*/
function mefFilePropertiesToJSArray($id,$value,$options=false){
// JS Array format :
//
// 00 - id,
// 01 - name,
// 02 - icon/thumbnail path
// 03 - downloadable (0 no, or 1 downloadable & viewable or 2 viewable only)
// 04 - mdownloadable (0 or 1)
// 05 - size text,
// Explorer
// 06 - unlinkable (0 or 1),
// 07 - renamable (0 or 1),
// 08 - excutable (0 or 1)
// Images
// 06 - size
// Audio
// 06 - title
static $filter=null;
if($filter===null) $filter=cfRGetVar('fileTypeFilter');
// ID, name
$output='Array('.$id.',"'.cfProtectFilename($value['name']).'",';
// Icon / thumbnail
if(isset($options['tnw'])) {
// If a thumbnail exists, base smaller thumbnail on it
if(isset($value['thumbnail'])) $output.='"'.cfExtImage(isset($value['thumbnail'])?$value['thumbnail']:$value['completeFileName'],$options['tnw'],$options['tnh'],true,0,array('sq'=>1)).'",';
else $output.='"'.cfExtImage($value['completeFileName'],$options['tnw'],$options['tnh'],true,0,array('sq'=>1)).'",';
}
elseif($filter==array('audio')) $output.='"",'; // Hard-coded icon in JS
else $output.='"'.$value['icon'].'",';
// Download / view file
if($value['rights']['download'] && cfRGetVar('downloadShortcut')) $output.='1,';
elseif($value['rights']['download']) $output.='2,';
else $output.='0,';
// Multiple download
if($value['rights']['download'] && cfRGetVar('multipleDownloadAllowed')) $output.='1,'; else $output.='0,';
// Size
$output.="'".addslashes(str_replace(' ',' ',efFileSizeFormat($value['size'])))."',";
if(!$filter || in_array('video',$filter)){
// Unlink
if($value['rights']['modify']) $output.='1,'; else $output.='0,';
// Rename
if($value['rights']['modify']) $output.='1,'; else $output.='0,';
// Execute
if($value['rights']['execute']) $output.='1'; else $output.='0';
}
elseif($filter==array('image')){
// Dimensions
$output.='"'.((isset($value['extra1']))?$value['extra1']:'').'"';
}
elseif($filter==array('audio')){
// Dimensions
$ai=efGetAudioInfo($value['completeFileName'],false);
$output.='"'.str_replace('"','"',cfUTF8Encode(((isset($ai['title']))?$ai['title']:$value['name']))).'"';
}
return $output.')';
}
/**
* @Desc output script needed for sync/async update of folders view
*
*/
function mefDisplayFolders(){
/**
* Nb files in directory
*/
$output='';
if(cfRGetVar('fileTypeFilter')==array('image')) $icon='icoImage';
elseif(cfRGetVar('fileTypeFilter')==array('audio')) $icon='icoMus';
elseif(cfRGetVar('fileTypeFilter')==array('video')) $icon='icoVid';
elseif(cfRGetVar('fileTypeFilter')==array('image','audio','video')) $icon='icoMultimedia';
else $icon='icoBlank';
if($_ENV['weezoResEfFiles']['nbFiles']==0) $icon='icoBlankNo';
// Switch to files view if empty folder
if($_ENV['weezoResEfFiles']['nbSubDirs']==0 && $_ENV['weezoResEfFiles']['nbFiles']>0 && (!isset($_POST['data3']) || $_POST['data3']!='setView'))
return mefDisplayFiles();
// Update script
$output='updtFolders("'.cfProtectFilename(cfResourceRelativePath(cfRGetVar('efCurrentDirectory'))).'","'.outIcon('fi/med/'.$icon).'","'.cfCaption('explorerFiles',$_ENV['weezoResEfFiles']['nbFiles']).'",Array(';
$i=0; $nb=0;
/**
* Upper directory
*/
if((cfFileRights(cfRGetVar('efCurrentDirectory')."/..",'state')=='authorized')){
$output.='".."';
$nb=1;
}
/**
* Subdirectories
*/
foreach ($_ENV['weezoResEfFiles'] as $file) if(is_array($file)){
if($file['type']=='file') continue;
if($i++<cfRGetVar('itemsPerPagePos')) continue;
if(cfRGetVar('itemsPerPage') && $nb>cfRGetVar('itemsPerPage')) break;
if($nb>0) $output.=',';
if($file['type']=='dir'){
$output.='"'.cfUTF8Encode($file['completeFileName']).'"';
}
elseif($file['type']=='drive'){
$output.='Array("'.cfUTF8Encode($file['completeFileName']).'","'.$file['icon'].'")';
}
$nb++;
}
$output.='),'.((cfRGetVar('itemsPerPagePos'))?1:0).','.((cfRGetVar('itemsPerPage') && $nb>cfRGetVar('itemsPerPage'))?1:0).')';
if(isset($_POST['asyncRequest'])){
echo cfAsyncXMLJSaction($output);
echo cfAsyncFooter();
exit;
}
else
echo '<script type="text/javascript">'.$output.'</script></body></html>';
}
/**
* @Desc output script needed for sync/async update of files view
*
*/
function mefDisplayFiles(){
$output ='updtFolders("'.cfProtectFilename(cfResourceRelativePath(cfRGetVar('efCurrentDirectory'))).'");';
$output.='updtFiles([';
$i=0;$nb=0;
$options=false;
$filter=cfRGetVar('fileTypeFilter');
// Compute images thumbnails dimensions
if(is_array($filter)&&in_array('image',$filter)){
$sw=max(cfGGetVar('userScreenWidth')-10,80);
$nbx=ceil($sw/100); $w=floor($sw/$nbx);
if($w<70) {$nbx--;$w=floor($sw/$nbx);}
$options=array('tnw'=>$w,'tnh'=>$w);
// iPhone
if(cfBGetVar('name')=='iPhone'){$w=100;$nbx=3;}
// Compute margin around images
$margin=max(1,($sw-($nbx*$w))/(2*$nbx));
$output='margin='.floor($margin).';'.$output;
}
// Audio files: include explorerFunctions for efGetAudioInfo
elseif(is_array($filter)&&in_array('audio',$filter)){require_once(INCLUDE_DIR.'explorerFunctions.php');}
// Number of thumbnails per page (round to above value to fill table)
if(isset($nbx)) {
$nbPP=$nbx*ceil(cfRGetVar('itemsPerPagePos')/$nbx);
$iPP=$nbx*ceil(cfRGetVar('itemsPerPage')/$nbx);
}
else {
$nbPP=cfRGetVar('itemsPerPagePos');
$iPP=cfRGetVar('itemsPerPage');
}
// Files information
foreach ($_ENV['weezoResEfFiles'] as $file) if(is_array($file) && $file['type']=='file'){
// Verify file is in displayed interval
if($i++<$nbPP) continue;
if(cfRGetVar('itemsPerPage') && $nb>=$iPP) break;
if($nb>0) $output.=',';
$output.=mefFilePropertiesToJSArray($i-1,$file,$options);
$nb+=1;
}
$output.='],'.((cfRGetVar('itemsPerPagePos'))?1:0).','.(($iPP && $nb>=$iPP)?1:0).')';
// Set thumbnails width/height and nb thumbnails / rows
if(is_array($filter)&&in_array('image',$filter)) $output='imgw='.$w.';imgh='.$w.';imgx='.$nbx.';'.$output;
if(isset($_POST['asyncRequest'])){
echo cfAsyncXMLJSaction($output);
echo cfAsyncFooter();
exit;
}
else
echo '<script type="text/javascript">'.$output.'</script></body></html>';
}
?>